from flask import Flask, request
from flask import render_template
from reserch import reserch4letters

app = Flask(__name__)

@app.route('/',methods=['GET','POST'])
def hello_world():
    return render_template('hello.html')

@app.route('/index',methods=['GET'])
def index():
    return render_template('index.html')

@app.route('/2048',methods=['GET'])
def game2048():
    return render_template('2048.html')

@app.route('/index1',methods=['POST','GET'])
def index1():
    return render_template('index1.html')


@app.route('/result',methods=['POST','GET'])
def result():
    py_firstname = request.form.get('firstName')
    py_lastname = request.form.get('lastName')
    py_fullname = py_firstname+' '+py_lastname
    return render_template("result.html",fullname = py_fullname)

@app.route('/result1',methods=['POST','GET'])
def result1():
    yuanyin = ['a','e','i','o','u']
    strforsearch = request.form.get('searchstr')
    py_found = {}
    for i in strforsearch:
        if i in yuanyin:
            py_found.setdefault(i, 0)
            py_found[i] += 1
    return render_template('result1.html',answer = py_found)

@app.route('/result2',methods=['POST','GET'])
def result2():
    rightaccount = 2731
    rightpassword = 147258
    loginaccount = request.form.get('account')
    loginpassword = request.form.get('password')
    if int(loginaccount) == rightaccount and int(loginpassword) == rightpassword:
        loginresult = '登录成功'
    else:
        loginresult = '账号或密码错误'

    return render_template('result2.html',loginResult = loginresult)


if __name__ == '__main__':
    app.run(host='127.0.0.1',port=5000,debug=True)
